/***
 *  Promise
 */

const promise = interview();
promise.then(res => {
    console.log(`res: ${res}`);
}).catch(err => {
    console.log(`err: ${err}`);
});


function interview() {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            if (Math.random() < 0.6) {
                resolve('success');
            } else {
                reject(new Error('fail'));
            }
        });
    });
};